package com.sync.syncmasterdata;


import com.fasterxml.jackson.databind.ObjectMapper;
import com.sync.syncmasterdata.customer.service.http.HttpAPIServiceForCrmSync;
import com.sync.syncmasterdata.util.NormalUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.platform.commons.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.concurrent.TimeUnit;

@SpringBootTest
@Slf4j
class SyncMasterDataApplicationTestsForRedis {

//    @Autowired
//    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private HttpAPIServiceForCrmSync httpAPIServiceForCrmSync;

    @Autowired
    private ObjectMapper objectMapper;
    private static final String WORKREDISPATH = "crm:new_type_2";

    @Value("${myprops.crmurl}")
    private String CRMURL;

    @Test
    void contextLoads() {
    }


    @Test
    public void redisTest() {
        //获取crm信息
//        String uPath = WORKREDISPATH;
//        String url=String.format("%s%s",CRMURL,"/new_work_types?$select=new_name,new_level,_new_superior_value&$filter=new_level eq 1");
//        url = NormalUtil.encodeUrl(url);
//        try {
//            String ret = httpAPIServiceForCrmSync.doGetCrm(url);
//            String retRedis=stringRedisTemplate.opsForValue().get(uPath);
//            if (StringUtils.isBlank(retRedis)) {
//                stringRedisTemplate.opsForValue().set(uPath, ret, 60, TimeUnit.SECONDS);
//                System.out.println("返回结果："+ret);
//            }else{
//                System.out.println("返回结果："+retRedis);
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }

    @Test
    public void test(){

        System.out.println("test");
    }



}
